home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-c / macc-carbon-demos-nonbinhex.sit / macc-carbon-demos-nonbinhex / chap23-demo-classic events / Drag.h < prev    next >
Text File  |  2001-05-31  |  5KB  |  133 lines

  1. // *******************************************************************************************
  2. // Drag.h                                                                  CLASSIC EVENT MODEL
  3. // *******************************************************************************************
  4. //
  5. // This program demonstrates drag and drop utilising the Drag Manager.  Support for Undo and
  6. // Redo of drag and drop within the source window is included.
  7. //
  8. // The bulk of the code in the source code file Drag.c is identical to the code in the file
  9. // Text1.c in the Chapter 20 TextEdit demonstration program MonoTextEdit.
  10. //
  11. // The program utilises the following resources:
  12. //
  13. // •  A 'plst' resource.
  14. //
  15. // •    An 'MBAR' resource, and 'MENU' resources for Apple, File, and Edit menus.
  16. //
  17. // •    A 'WIND' resource (purgeable) (initially visible).
  18. //
  19. // •    'CNTL' resources (purgeable) for the vertical scroll bars in the text editor window and
  20. //        Help dialog, and for the pop-up menu in the Help Dialog.
  21. //
  22. // •    A 'STR#' resource (purgeable) containing error text strings.
  23. //
  24. // •    A 'SIZE' resource with the acceptSuspendResumeEvents, canBackground, 
  25. //        doesActivateOnFGSwitch, and isHighLevelEventAware flags set.
  26. //
  27. // *******************************************************************************************
  28.  
  29. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
  30.  
  31. #include <Carbon.h>
  32.  
  33. // …………………………………………………………………………………………………………………………………………………………………………………………………………………………… defines
  34.  
  35. #define rMenubar                    128
  36. #define mAppleApplication    128
  37. #define  iAbout                        1
  38. #define mFile                            129
  39. #define  iNew                            1
  40. #define  iOpen                        2
  41. #define  iClose                        4
  42. #define  iSaveAs                    6
  43. #define  iQuit                        12
  44. #define mEdit                            130
  45. #define  iUndo                        1
  46. #define  iCut                            3
  47. #define  iCopy                        4
  48. #define  iPaste                        5
  49. #define  iClear                        6
  50. #define  iSelectAll                7
  51. #define rWindow                        128
  52. #define rVScrollbar                128
  53. #define rErrorStrings            128
  54. #define  eMenuBar                    1
  55. #define  eWindow                    2
  56. #define  eDocStructure        3
  57. #define  eTextEdit                4
  58. #define  eExceedChara            5
  59. #define  eNoSpaceCut            6
  60. #define  eNoSpacePaste        7
  61. #define  eDragHandler            8
  62. #define  eDrag                        9
  63. #define  eDragUndo                10
  64. #define kMaxTELength            32767
  65. #define kTab                            0x09
  66. #define kDel                            0x7F
  67. #define kReturn                        0x0D
  68. #define topLeft(r)                (((Point *) &(r))[0])
  69. #define botRight(r)                (((Point *) &(r))[1])
  70.  
  71. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… typedefs
  72.  
  73. typedef struct
  74. {
  75.     TEHandle        textEditStrucHdl;
  76.     ControlRef    vScrollbarRef;
  77.     WindowRef        windowRef;
  78.     Boolean            windowTouched;
  79.     Handle            preDragText;
  80.     SInt16            preDragSelStart;
  81.     SInt16            preDragSelEnd;
  82.     SInt16            postDropSelStart;
  83.     SInt16            postDropSelEnd;
  84. } docStructure, *docStructurePointer;
  85.  
  86. // …………………………………………………………………………………………………………………………………………………………………………………………… function prototypes
  87.  
  88. void            main                                        (void);
  89. void            doPreliminaries                    (void);
  90. OSErr            quitAppEventHandler            (AppleEvent *,AppleEvent *,SInt32);
  91. void            eventLoop                                (void);
  92. void            doIdle                                    (void);
  93. void            doEvents                                (EventRecord *);
  94. void            doKeyEvent                            (SInt8);
  95. void          scrollActionFunction        (ControlRef,SInt16);
  96. void            doInContent                            (EventRecord *);
  97. void            doUpdate                                (EventRecord *);
  98. void            doActivate                            (EventRecord *);
  99. void            doActivateDocWindow            (WindowRef,Boolean);
  100. void            doOSEvent                                (EventRecord *);
  101. WindowRef    doNewDocWindow                    (void);
  102. Boolean        customClickLoop                    (void);
  103. void            doSetScrollBarValue            (ControlRef,SInt16 *);
  104. void            doAdjustMenus                        (void);
  105. void            doMenuChoice                        (SInt32);
  106. void            doFileMenu                            (MenuItemIndex);
  107. void            doEditMenu                            (MenuItemIndex);
  108. SInt16        doGetSelectLength                (TEHandle);
  109. void            doAdjustScrollbar                (WindowRef);
  110. void            doAdjustCursor                    (WindowRef);
  111. void            doCloseWindow                        (WindowRef);
  112. void            doSaveAsFile                        (TEHandle);
  113. void            doOpenCommand                        (void);
  114. void            navEventFunction                (NavEventCallbackMessage,NavCBRecPtr,NavCallBackUserData);
  115. void            doOpenFile                            (FSSpec);
  116. void            doErrorAlert                        (SInt16);
  117.  
  118. OSErr            doStartDrag                            (EventRecord *,RgnHandle,TEHandle);
  119. OSErr         dragTrackingHandler            (DragTrackingMessage,WindowRef,void *,DragRef);
  120. SInt16        doGetOffset                            (Point,TEHandle);
  121. SInt16        doIsOffsetAtLineStart        (SInt16,TEHandle);
  122. void            doDrawCaret                            (SInt16,TEHandle);
  123. SInt16        doGetLine                                (SInt16,TEHandle);
  124.  
  125. OSErr            dragReceiveHandler            (WindowRef,void *,DragRef);
  126. Boolean        doIsWhiteSpaceAtOffset    (SInt16,TEHandle);
  127. Boolean      doIsWhiteSpace                    (char);
  128. char            doGetCharAtOffset                (SInt16,TEHandle);
  129. SInt16        doInsertTextAtOffset        (SInt16,Ptr,SInt32,TEHandle);
  130. Boolean        doSavePreInsertionText    (docStructurePointer);
  131. void            doUndoRedoDrag                    (WindowRef);
  132.  
  133. // *******************************************************************************************